<template>
  <HomePanel ref="target" title="最新专题">
    <template #right>
      <XtxMore style="line-height: 22px" />
    </template>
    <Transition name="fade">
      <div class="special-box" v-if="list.length">
        <div class="special-item" v-for="item in list" :key="item.id">
          <RouterLink class="like" to="/">
            <img :src="item.cover" alt="" />
            <div class="img_pos">
              <p class="title">
                <span class="ellipsis top">{{ item.title }}</span>
                <span class="ellipsis buttom_title">{{ item.summary }}</span>
              </p>
              <span class="price-right">￥{{ item.lowestPrice }}起</span>
            </div>
          </RouterLink>
          <div class="icon_num">
            <div>
              <span class="left-love">
                <i class="iconfont icon-hart1"></i>
                {{ item.collectNum }}
              </span>
              <span>
                <i class="iconfont icon-see"></i>
                {{ item.viewNum }}
              </span>
            </div>
            <div>
              <span>
                <i class="iconfont icon-message"></i>
                {{ item.replyNum }}
              </span>
            </div>
          </div>
        </div>
      </div>
      <!-- 骨架效果 -->
      <div class="home-special" v-else>
        <div class="item" v-for="i in 3" :key="i">
          <XtxSkeleton bg="#e4e4e4" width="404px" height="288px" animated />
          <XtxSkeleton class="skeleton-tlite" bg="#e4e4e4" width="380px" height="30px" animated />
        </div>
      </div>
    </Transition>
  </HomePanel>
</template>

<script>
import HomePanel from './home-panel.vue'
import { getSpecial } from '@/api/home.js'
import { useLazyData } from '@/utils/hoods.js'
export default {
  components: {
    HomePanel
  },
  setup() {
    const { target, list } = useLazyData(getSpecial)
    return {
      target,
      list
    }
  }
}
</script>

<style lang="less" scoped>
.home-panel {
  background-color: #f5f5f5;
}
.special-box {
  height: 380px;
  display: flex;
  justify-content: space-between;
  padding-bottom: 20px;
  .special-item {
    width: 404px;
    background-color: #fff;
    transition: all 0.5s;
    &:hover {
      transform: translate3d(0, -3px, 0px);
      box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
    }
    .like {
      width: 100%;
      height: 288px;
      display: block;
      position: relative;
      .img_pos {
        width: 404px;
        height: 288px;
        position: absolute;
        top: 0;
        left: 0;
        background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.8), transparent 50%);
      }
      .title {
        width: 70%;
        height: 70px;
        position: absolute;
        left: 20px;
        bottom: 10px;
        font-size: 22px;
        color: #fff;
        .top {
          display: block;
          margin-bottom: 5px;
        }
        .buttom_title {
          display: block;
          color: #999;
        }
      }
      .price-right {
        position: absolute;
        bottom: 25px;
        right: 16px;
        background-color: #fff;
        border-radius: 2px;
        font-size: 17px;
        color: #cf4444;
        line-height: 1; // 设置成数字是根据字体大小的乘积（行高数字*字体大小）来设置行高
        padding: 4px 8px 4px 7px;
      }
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }
    .icon_num {
      height: 72px;
      display: flex;
      justify-content: space-between;
      padding: 0 20px;
      div {
        display: flex;
        align-items: center;
        span {
          font-size: 16px;
        }
        i {
          color: #999;
        }
      }
      .left-love {
        margin-right: 10px;
      }
    }
  }
}
.home-special {
  height: 380px;
  display: flex;
  justify-content: space-between;
  .item {
    display: flex;
    flex-direction: column;
    align-items: center;
    ::v-deep .skeleton-tlite {
      margin-top: 20px;
    }
  }
}
</style>
